<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>地图 - 详情 - 缺陷维修管理 - 管体缺陷</title></head>
<body>
    <!-- repairTaskId -->
    <input name="defectInfoId" id="JQ_defectInfoId" value="${param.defectInfoId}" type="hidden">
    <input name="projectName" id="JQ_projectName" value="${param.projectName}" type="hidden">
    <!-- content -->
    <div class="main-content">
        <!-- content-body -->
        <div class="main-inner">
            <div class="content-inner">
                <div class="meta-head">
                    <h3><i class="zy-tools-icon"></i>缺陷维修管理 <i class="zy-url-arrow"></i> 详情 <i class="zy-url-arrow"></i> 地图</h3>
                </div>
                <div class="meta-info">
                    <p><span id="JQ_location_name_01"></span> 缺陷点位置信息</p>
                    <dl id="JQ_defect_table" class="meta-dl">
                        <dd>管道名称：-</dd>
                        <dd>缺陷点编号：-</dd>
                        <dd>绝对距离(m)：-</dd>
                        <dd>缺陷类型：-</dd>
                        <dd>长/宽/深(mm)：-/-/-</dd>
                        <dd>时钟位置(h:min)：-</dd>
                        <dd>ERF：-</dd>
                        <dd>修复方法：-</dd>
                        <dd>修复状态：-</dd>
                    </dl>
                    <div class="clear"></div>
                </div>
                <div class="zy-table">
                    <h4>定位位置展示</h4>
                    <div class="zy-map-inner">
                        <iframe src="/gis/default/webmap/baseMapDefectRepair.jsp" id="JQ_dyMap" name="dyMap" scrolling="0" frameborder="0" width="100%" height="100%"></iframe>
                    </div>
                </div>
                <div class="zy-table">
                    <h4>定位位置展示</h4>
                    <table class="zy-datatable" cellpadding="0" cellspacing="0">
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>类型</th>
                            <th>绝对距离(m)</th>
                            <th>距目标点距离(m)</th>
                            <th>上游交汇时钟位置</th>
                            <th>下游交汇时钟位置</th>
                        </tr>
                        </thead>
                        <tbody id="JQ_location_table">
                        <tr>
                            <td>-</td>
                            <td>-</td>
                            <td>-</td>
                            <td>-</td>
                            <td>-</td>
                            <td>-</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="zy-form-line t-r" style="background-color: #ffffff; padding-right: 15px;">
                <button type="button" class="zy-button zy-goback" id="JQ_go_back"><i class="zy-goback-icon"></i>返回</button>&nbsp;&nbsp;&nbsp;&nbsp;
                <button type="button" class="zy-button zy-submit" id="JQ_down_pdf">下载PDF</button>
            </div>
            <!-- export pdf hidden div -->
            <div class="hidden" id="t_canvas_div"></div>
        </div>
    </div>
    <!-- plugin -->
    <script src="${pageContext.request.contextPath}/static/js/plugin/datatables/js/jquery.dataTables.min.js"></script>
    <!-- ui -->
    <script src="${pageContext.request.contextPath}/static/js/ui/ui-main.js"></script>
    <!-- base -->
    <script src="${pageContext.request.contextPath}/static/js/controller/base/base.controller.js"></script>
    <!-- api -->
    <script src="${pageContext.request.contextPath}/static/js/controller/api/defect.api.js"></script>
    <!-- controller -->
    <script src="${pageContext.request.contextPath}/static/js/controller/defect/repair/repairLocationMap.controller.js"></script>
    <!-- down pdf -->
    <script src="${resourcePath }/js/html2canvas.js"></script>
    <script src="${resourcePath }/js/canvg.js"></script>
    <script src="${resourcePath }/js/rgbcolor.js"></script>
    <script>
        $('#JQ_down_pdf').click(function(){
            var $this = $(this);
            var $canvas_div = $('#t_canvas_div');
            var pipeLineName = $('#JQ_defect_table span[title]').eq(0).attr('title');
            var defectInfoType = $('#JQ_defect_table span[title]').eq(1).attr('title');
            var projectName = eval('"' + $('#JQ_projectName').val() + '"');
            var name = projectName + defectInfoType + "参考点信息";
            var fileName = pipeLineName + projectName + defectInfoType + "参考点信息";

            DyyBase.isLogin(function(){
                $this.EXPT({
                    type: 'name',
                    name: fileName,
                    yesBtnAct: function(callback,fname){
                        callback();

                        var $ifr_dyMap = $('#JQ_dyMap');
                        var $ifr_body = $($ifr_dyMap[0].contentWindow.document.getElementById('mask_layers'));
                        /*处理IE下兼容*/
                        var html1_1 = $ifr_body.html();
                        var _svg_html = html1_1.substring(html1_1.indexOf("<svg"));
                        var $t_canvas = $('<canvas id="t_canvas"></canvas>');

                        $canvas_div.append($t_canvas);

                        canvg("t_canvas",_svg_html,{
                            //ignoreMouse: true,
                            //ignoreAnimation: true
                        });

                        var _svg = $ifr_dyMap[0].contentWindow.document.getElementById('mask_gc');
                        //$(_svg).remove();//删掉svg
                        $ifr_body.append($t_canvas);//画布填充到iframe
                        $canvas_div.empty();//
                        //aaa
                        //var aaaa = $ifr_body.html().replace(/proxy.jsp\?/g,'');
                        //var $aaaa = $(aaaa);
                        //$ifr_body.append($aaaa);
                        html2canvas($ifr_body, {
                            proxy: DyyBase.root_path+ '/comm/downNetFile.json',
                            onrendered: function (canvas) {
                                var url = canvas.toDataURL();
                                var $img = $('<img style="width: 100%; height: 100%">').attr('src', url);
                                $ifr_dyMap.after($img).hide();//appendTo($('#t_canvas_div'))
                                
                                html2canvas($('.content-inner')).then(function(canvas) {
                                    var url = canvas.toDataURL();
                                    $img = $img.attr('src', url);

                                    $ifr_dyMap.show();
                                    $img.remove();
                                    $ifr_body.find('#t_canvas').remove();//删除画布
                                    //$ifr_body.append(_svg);//重新显示svg
                                    //$aaaa.remove();
                                    var param = [{name:'name',value:name},{name:'fileName',value:fname},{name:'imgs',value: url},{name:'ydm',value: false}];
                                    s_downFile(DyyBase.root_path+ '/comm/downImgPdf.json',param);

                                });
                            }
                        });
                    }
                });
            });
        });
    </script>
</body>
</html>
